Ext.define('DragonApp.view.journal.Query', {
    extend: 'Ext.form.Panel',
    alias: ['widget.journalquery'],

    requires: [
        'DragonApp.view.pub.form.field.CharacterID',
        'DragonApp.view.pub.combobox.Server',
        'Ext.ux.combobox.TreeCombo'
    ],

    controller: 'journal',
    reference: 'journalform',

    bodyPadding: 5,
    border: false,

    fieldDefaults: {
        labelWidth: 60,
        labelAlign: 'right'
    },

    items: [{
            xtype: 'fieldcontainer',
            layout: 'hbox',
            defaults: {
                listeners: {
                    specialKey: 'onTextFieldSpecialKey'
                },
                margin: '0 10 0 0'
            },
            items: [
                { xtype: "servercombobox", name: "sid", fieldLabel: "服务器", width: 238 },
                { xtype: "textfield_cid", name: "id", fieldLabel: "玩家ID", width: 238 },
                { xtype: "textfield", name: "nickname", fieldLabel: "玩家名", width: 238 },
                {
                    xtype: "treecombo",
                    name: "operation",
                    fieldLabel: "操作",
                    width: 238,
                    allowBlank: false,
                    selectChildren: false,
                    canSelectFolders: true,
                    store: Ext.create('DragonApp.store.Journal', {})
                }
            ]
        },
        {
            xtype: 'fieldcontainer',
            layout: 'hbox',
            defaults: {
                listeners: {
                    specialKey: 'onTextFieldSpecialKey'
                },
                margin: '0 10 0 0'
            },
            items: [
                { xtype: "datefield", name: "startdate", fieldLabel: "开始日期", maxValue: new Date(), format: 'Y-m-d', emptyText: '请选择', width: 238 },
                { xtype: "datefield", name: "enddate", fieldLabel: "结束日期", value: new Date(), format: 'Y-m-d', emptyText: '请选择', width: 238 }
            ]
        }
    ],
    buttons: [{
        text: '取消',
        handler: function() {

            //清空查询表单
            var form = this.up('form').getForm();
            form.reset();

            //清空查询结果
            var grid = Ext.ComponentQuery.query('journalgrid')[0];
            grid.getStore().removeAll();
        }
    }, {
        text: '查询',
        formBind: true,
        disabled: true,
        handler: 'onSubmitClick'
    }]
});